home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-12-12 | 4.2 KB | 168 lines | [TEXT/MSET] |
- (special note: This description of the Mops floating point environment is
- incomplete. Please refer to the Mops file floating point and the Apple
- Numerics Manual for detail complete information.)
-
- GENERAL
-
- A floating point number (flt) is input by placing a decimal point anywhere in
- the number. There is no separate stack for floats, they are accessed via
- pointers on the normal stack.
-
- All numbers to be input as floats must contain one decimal point.
-
- The numeric base may be other than decimal when using floating point. Floats
- will always be interpretted in base 10 regardless of base. Non-floats (no
- decimal point) will be interpretted in the current base.
-
- The general form for a float is as follows:
-
- Sxxx.yyyEszz There can be NO blanks between the components of a float.
-
- S = optional sign of mantissa (+ or - or blank)
- xxx.yyy = required mantissa with required decimal (must have xxx or yyy or both)
- E = optional exponent delimiter (may be e)
- s = optional sign of exponent
- zz = optional exponent, must be preceded by E
-
- Note that local variables and named input parameters to be used for floating point
- numbers must have their names preceded by %.
-
-
- NUMERIC CONVERSION
-
- FLOAT> \ ( flt -- n ) Converts the float to an int, rounds.
- >FLOAT \ ( n -- flt ) Converts the int to a float.
-
-
- MEMORY
-
- FVALUE flt -- : name Fp analog of value, can use prefix operators.
- FCON flt -- : name Fp analog of constant.
-
-
-
- STACK MANIPULATION
-
-
- FDUP flt -- flt flt
- FOVER flt1 flt2 -- flt1 flt2 flt1
- F2DUP flt1 flt2 -- flt1 flt2
- FDROP flt --
- F2DROP flt1 flt2 --
-
- \ ========= Dyadic comparisons ==========
- Stack frame for all dyadic comparisons: ( flt1 flt2 -- b )
- F>
- F<
- F≥
- F≤
- F=
- F≠
-
- \ ========= Monadic comparisons ==========
- Stack frame for all monadic comparisons: ( flt -- b )
-
- F0=
- F0≠
- F0≥
- F0<
- F0≤
- F0>
-
- \ =============== Arithmetic operators ==============
-
- \ ( flt1 flt2 -- flt1<op>flt2 ) Result gets stored in flt1's data.
-
- F+
- F-
- F*
- F/
-
- PREFIX OPERATORS Use for fvalues, local fvariables, named input parameters.
-
- -> flt -- : word Gazinta. Stores flt.
- ++> flt -- : word Adds flt.
- --> flt -- : word Subtracts flt.
- NEG> -- : word Negates.
-
- *> flt -- : word Multiplies by flt.
- /> flt -- : word Divides by flt.
- ABS> -- : word Changes to absolute value.
-
-
- \ ============= Monadic operations ==============
-
- \ FNEGATE and FABS simply operate on the sign bit, so we don't need to call
- SANE at all. The SANE manual actually recommends this.
-
- FNEGATE
- FABS
- SQRT
- ROUND
- TRUNC
-
-
-
- \ ===================================
- \ FP to/from decimal conversion
- \ ===================================
-
- E.R ( flt wid -- ) Prints the floating point number in scientific notation
- in a field wid characters wide.
- wide
- E. ( flt -- ) \ same as 26 e.r
- F.R ( flt wid -- ) Prints the floating point number without exponents in a
- field wid characters wide.
- FCONV? { addr len -- flt T | -- F }
- \ Converts the passed-in ASCII string to
- \ floating, if possible. I like this name better
- \ than ATOF which Neon had, but change it back if
- \ you want to.
-
- \ =================================
- \ Transcendentals
- \ =================================
-
- LN \ Natural log
- LOG2 \ Base 2 log
- LN1 \ ln(1+x)
- LOG21 \ log2(1+x). I don't think LOG21 is a very helpful name (pure
- \ computerese), but I guess we're stuck with it.
- EXP \ Base e exponential
- EXP2 \ Base 2 exponential
- EXP1 \ e**x - 1
- EXP21 \ 2**x - 1
- **N \ ( x n -- x**n ) Integer exponentiation. This wasn't
- \ in Neon, but might be useful. Note this operation
- \ ignores the high-order 16 bits of n.
- F** \ ( x y -- x**y ) General exponentiation - takes 2 floats.
- \ Here I think the Neon name was crazy. But we've still
- \ got it below for compatibility.
-
- \ Trig functions.
-
- DEG2RAD \ ( deg -- rad ) Converts degrees to radians
- RAD2DEG \ ( rad -- deg ) Converts radians to degrees
-
- The following require radians as input.
- SIN
- COS
- TAN
- ARCTAN
- COT \ ( x -- cot(x) ) Cotangent of x
-
- FRAND \ floating-pt random number routine
-
- \ ======================================
- \ Sundry useful constants and operations
- \ ======================================
- 1.0 exp fcon E
- 10.0 ln fcon LN(10)
- PI
- UNDEF \ Ditto
-
- 1/X
- LOG \ ( x -- log(x) ) Log base 10 of x
- ANTILOG \ ( x -- antilog(x) ) Antilog ( 10^x ) of x
-
-